package com.tuanzi.loan.business.service.family.impl;

import com.google.common.collect.Lists;
import com.tuanzi.loan.business.repository.family.LoanApiOrderRepaymentRepository;
import com.tuanzi.loan.business.service.family.LoanApiOrderRepaymentService;
import com.tuanzi.loan.core.aspect.Debug;
import com.tuanzi.loan.core.vo.PageSearcher;
import com.tuanzi.loan.vo.request.family.LoanApiOrderRepaymentSearchRequest;
import com.tuanzi.loan.vo.response.family.LoanApiOrderRepaymentSearchResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.retry.RetryException;
import org.springframework.retry.annotation.Retryable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Debug
@Service
@Transactional
@Retryable(value = { RetryException.class })
public class LoanApiOrderRepaymentServiceImpl implements LoanApiOrderRepaymentService{
    @Autowired
    LoanApiOrderRepaymentRepository repository;
    @Override
    public Page<LoanApiOrderRepaymentSearchResponse> list(PageSearcher<LoanApiOrderRepaymentSearchRequest> pageSearcher) {
        Page<LoanApiOrderRepaymentSearchResponse> result = repository.list(pageSearcher.getSearchCondition(),pageSearcher.getPageable());
        if (result.getTotalElements()==1l){
            return  new PageImpl(Lists.newArrayList());
        }else{
            return result;
        }
    }
}
